﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElingOA6_Admin_DSJCJ.Model
{
    /// <summary>
    /// 实体类SysTemplate 。(属性说明自动提取数据库字段的描述信息)
    /// </summary>
    [Serializable]
    public class SysTemplate
    {
        public SysTemplate()
        { }
        #region Model
        private decimal _ftemplateid;
        private string _fentityno;
        private string _ftemplatecls;
        private string _fsourceno;
        private string _ftemplatetype;
        private string _ftitle;
        private byte[] _fcontent;
        private string _ffilename;
        private string _fisdefault;
        /// <summary>
        /// 
        /// </summary>
        public decimal FTemplateID
        {
            set { _ftemplateid = value; }
            get { return _ftemplateid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string FEntityNo
        {
            set { _fentityno = value; }
            get { return _fentityno; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string FTemplateCls
        {
            set { _ftemplatecls = value; }
            get { return _ftemplatecls; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string FSourceNo
        {
            set { _fsourceno = value; }
            get { return _fsourceno; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string FTemplateType
        {
            set { _ftemplatetype = value; }
            get { return _ftemplatetype; }
        }

        /// <summary>
        /// 
        /// </summary>
        public string FTType
        {
            get
            {
                if (FTemplateType == "O")
                {
                    int t = FFileName.LastIndexOf(".");
                    if (t != -1)
                    {
                        string officename = FFileName.Substring(t + 1);
                        if (officename == "doc" || officename == "docx")
                        {
                            return "W";
                        }
                        else if (officename == "xls" || officename == "xlsx")
                        {
                            return "E";
                        }
                        else
                        {
                            return "P";
                        }
                    }
                    else
                    {
                        return "";
                    }
                }
                else
                {
                    return "H";
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public string FTitle
        {
            set { _ftitle = value; }
            get { return _ftitle; }
        }
        /// <summary>
        /// 
        /// </summary>
        public byte[] FContent
        {
            set { _fcontent = value; }
            get { return _fcontent; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string FFileName
        {
            set { _ffilename = value; }
            get { return _ffilename; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string FIsDefault
        {
            set { _fisdefault = value; }
            get { return _fisdefault; }
        }
        #endregion Model


        public string TemImg
        {
            get
            {
                string str = "/Content/ControlImages/tem_folder.png";

                string trye = "";
                if (FTemplateType == "O")
                {
                    trye = FFileName.Substring(FFileName.LastIndexOf(".") + 1).ToLower();
                    switch (trye)
                    {
                        case "doc": str = "/Content/ControlImages/tem_word.png"; break;
                        case "docx": str = "/Content/ControlImages/tem_word.png"; break;
                        case "xls": str = "/Content/ControlImages/tem_excel.png"; break;
                        case "xlsx": str = "/Content/ControlImages/tem_excel.png"; break;
                        case "ppt": str = "/Content/ControlImages/tem_ppt.png"; break;
                        case "pptx": str = "/Content/ControlImages/tem_ppt.png"; break;
                    }
                }
                else
                {
                    str = "/Content/ControlImages/tem_htm_ie.png"; 
                }
                return str;
            }
        }


        public string ShortName
        {
            get
            {
                if (null != FTitle)
                {
                    if (FTitle.Length > 11)
                    {
                        return FTitle.Substring(0, 11) + "...";
                    }
                    else
                    {
                        return FTitle;
                    }
                }
                else
                {
                    return string.Empty;
                }
            }

        }

    }
}
